package 笔试;

import java.util.Scanner;

public class 蚂蚁_小红的查询区域 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int q = scan.nextInt();
        scan.nextLine();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scan.nextInt();
        }
        int[][] arr = new int[q][3];
        for (int i = 0; i < q; i++) {
            for (int j = 0; j < 3; j++) {
                arr[i][j] = scan.nextInt();
            }
            scan.nextLine();
        }

        for (int i = 0; i < q; i++) {
            if(arr[i][0] == 1) {
                if(arr[i][1] <= n) {
                    int tmp = arr[i][1]-1;
                    nums[tmp] = arr[i][2];
                }
            } else if(arr[i][0] == 2){
                int count = 0;
                for (int j = 0; j < arr[i][1]; j++) {
                    if(nums[j] == arr[i][2]) {
                        count = count+1;
                    }
                }
                System.out.println(count);
            }
        }
    }
}
